<template>
	<div ref="logDialog" class="dialog-wrap">
		
		<el-dialog
			class="sys-admin-dialog" 
			:title="headerTitle" 
			width="70%" 
			:visible.sync="dialogVisible"
			@close="dialogClose"
		>
			
			<el-row :gutter="20">
				<el-form 
					v-if = "editForm != null"
					size="mini"
					ref="dialogForm"
					:label-width="formLabelWidth"
					:model.sync="editForm">
					
					<el-col :span="12">
						<el-form-item label="日志类型">
		      				<el-input v-model="editForm.logType" autocomplete="off" readonly disabled></el-input>
		    			</el-form-item>
		    		</el-col>
		    		
		    		
		    		
		    		<el-col :span="12">	
		    			<el-form-item label="日志名称">
		      				<el-input v-model="editForm.logName" autocomplete="off" readonly disabled></el-input>
		    			</el-form-item>
		    		</el-col>

		    		<el-col :span="12">	
		    			<el-form-item label="用户名称">
		      				<el-input v-model="editForm.userName" autocomplete="off" readonly disabled></el-input>
		    			</el-form-item>
		    		</el-col>
		    		
		    		<el-col :span="12">	
		    			<el-form-item label="类名">
		      				<el-input v-model="editForm.className" autocomplete="off" readonly disabled></el-input>
		    			</el-form-item>
		    		</el-col>

		    		<el-col :span="12">	
		    			<el-form-item label="方法名">
		      				<el-input v-model="editForm.method" autocomplete="off" readonly disabled></el-input>
		    			</el-form-item>
		    		</el-col>

		    		<el-col :span="12">	
		    			<el-form-item label="时间">
		      				<el-input v-model="editForm.createTime" autocomplete="off" readonly disabled></el-input>
		    			</el-form-item>
		    		</el-col>

		    		<el-col :span="24">	
		    			<el-form-item label="信息" prop="description">
		      				<el-input type="textarea" v-model="editForm.message" autocomplete="off" rows="5" readonly disabled></el-input>
		    			</el-form-item>
		    		</el-col>
		    		
		    		<el-col :span="24">	
		    			<el-form-item label="错误" prop="description">
		      				<el-input type="textarea" v-model="editForm.regularMessage" autocomplete="off" rows="20" readonly disabled></el-input>
		    			</el-form-item>
		    		</el-col>

				</el-form>
			</el-row>
			
			<div slot="footer" class="dialog-footer">
			    <el-button size="mini" @click="cancel">退出</el-button>
			</div>	
		</el-dialog>

	</div>
</template>


<script>
import { getList } from "@/api/admin/dept";
export default{
	props:{
		//新增还是编辑
	    type:{
	      type:[Number,String],
	      defalut:0
	    },
		visible:{
			type:Boolean,
			default:false
		},
		form:{
			type:Object,
			default:null
		}
	},
	computed:{
	
	},
	watch:{
		form(newVal,oldVal){
			
			if(newVal != null){
				this.editForm = newVal;
			}else{
				this.editForm = this.defaultForm;
			}	
		},
		type(newVal,oldVal){
	      	if(newVal == 1){
	        	this.headerTitle = "查看日志";
	        	this.editForm = this.defaultForm;
	      	}else if(newVal == 2){
	        	this.headerTitle = "查看日志";
	        	this.editForm = this.form;
	      	}else if(newVal == 3){
	      		this.headerTitle = "查看日志";
	        	this.editForm = this.form;
	      	}
	    },
	    visible(val){
	    	this.dialogVisible = val;
	    }
	},
	data(){
		return{
			headerTitle:"查看日志",
			dialogVisible:false,
			defaultForm:{
				logType:'',
				logName:'',
				userName:'',
				className:'',
				method:'',
				createTime:'',
				message:'',
				regularMessage:'',
			},
			editForm:null,
			formLabelWidth:'100px',
		}
	},
	methods:{
		dialogClose(){
			this.cancel();
		},
		//取消按钮
		cancel(){
			this.editForm = null;
			this.dialogVisible = false;
			this.$emit('cancel')
		}
	}
}


</script>

<style>
	.sys-admin-dialog .el-dialog{
		margin-bottom: 50px;
	}
</style>